package com.ruoyi.gas.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gas.domain.GasDf;
import com.ruoyi.gas.service.IGasDfService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 东方报警数据Controller
 * 
 * @author ruoyi
 * @date 2024-01-17
 */
@RestController
@RequestMapping("/gas/df")
public class GasDfController extends BaseController
{
    @Autowired
    private IGasDfService gasDfService;

    /**
     * 查询东方报警数据列表
     */
    @PreAuthorize("@ss.hasPermi('gas:df:list')")
    @GetMapping("/list")
    public TableDataInfo list(GasDf gasDf)
    {
        startPage();
        List<GasDf> list = gasDfService.selectGasDfList(gasDf);
        return getDataTable(list);
    }

    /**
     * 导出东方报警数据列表
     */
    @PreAuthorize("@ss.hasPermi('gas:df:export')")
    @Log(title = "东方报警数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GasDf gasDf)
    {
        List<GasDf> list = gasDfService.selectGasDfList(gasDf);
        ExcelUtil<GasDf> util = new ExcelUtil<GasDf>(GasDf.class);
        util.exportExcel(response, list, "东方报警数据数据");
    }

    /**
     * 获取东方报警数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('gas:df:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gasDfService.selectGasDfById(id));
    }

    /**
     * 新增东方报警数据
     */
    @PreAuthorize("@ss.hasPermi('gas:df:add')")
    @Log(title = "东方报警数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GasDf gasDf)
    {
        return toAjax(gasDfService.insertGasDf(gasDf));
    }

    /**
     * 修改东方报警数据
     */
    @PreAuthorize("@ss.hasPermi('gas:df:edit')")
    @Log(title = "东方报警数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GasDf gasDf)
    {
        return toAjax(gasDfService.updateGasDf(gasDf));
    }

    /**
     * 删除东方报警数据
     */
    @PreAuthorize("@ss.hasPermi('gas:df:remove')")
    @Log(title = "东方报警数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gasDfService.deleteGasDfByIds(ids));
    }
}
